Every application executing in System 7, as well as every application executing under MultiFinder, should contain a size ( 'SIZE' ) resource. One of the principal functions of the 'SIZE' resource is to inform the Operating System about the memory size requirements for the application so that the Operating System can set up an appropriately sized partition for the application. The 'SIZE' resource is also used to indicate certain scheduling options to the Operating System, such as whether the application can accept suspend and resume events. The 'SIZE' resource in System 7 contains additional information indicating whether the application is 32-bit clean, whether it supports stationery documents, whether it uses TextEdit's inline input services, whether the application wishes to receive notification of the termination of any applications it has launched, and whether the application wishes to receive high- level events.
A 'SIZE' resource consists of a 16-bit flags field followed by two 32-bit size fields. The flags field specifies operating characteristics of the application, and the size fields indicate the minimum and preferred partition sizes for the application. The minimum partition size is the actual limit below which your application will not run. The preferred partition size is the memory size at which your application can run most effectively and which the Operating System attempts to secure upon launching the application. If that amount of memory is unavailable, the application is placed into the largest contiguous block available, provided that it is larger than the specified minimum size.
If the amount of available memory is between the minimum and the preferred sizes, the Finder displays a dialog box asking if the user wants to run the application using the amount of memory available. If your application does not have a 'SIZE' resource, it is assigned a default partition size of 512 KB and the Process Manager uses a default value of false for all specifications normally defined by constants in the flags field.
When you define a 'SIZE' resource, you should give it a resource ID of -1. A user can modify the preferred size in the Finder's information window for your application. If the user does alter the preferred partition size, the Operating System creates a new 'SIZE' resource having resource ID 0. The Process Manager also creates a new 'SIZE' resource when the user modifies any of the other settings in the resource.
In system software version 7.1 the user can also modify the minimum size in the Finder's information window for your application. In version 7.1, if the user alters either the minimum or the preferred partition size, the Operating System creates two new 'SIZE' resources, one with resource ID 0 and one with resource ID 1.
At application launch time, the Process Manager looks for a 'SIZE' resource with ID 0 for the preferred partition size; if this resource is not found, it uses your original 'SIZE' resource with ID -1. In version 7.1, the Process Manager looks for a 'SIZE' resource with ID 0 for the preferred size and looks for a 'SIZE' resource with ID 1 for the minimum size; if these resources are not found, it uses your original 'SIZE' resource with ID -1.
Listing 1 shows the structure of the 'SIZE' resource in Rez format.
Listing 1 A Rez template for a 'SIZE' resource
type 'SIZE' {
boolean reserved; /* reserved */
boolean ignoreSuspendResumeEvents, /* ignores suspend-resume events */
acceptSuspendResumeEvents; /* accepts suspend-resume events */
boolean reserved; /* reserved */
boolean cannotBackground, /* can't use background null events */
canBackground; /* can use background null events */
boolean needsActivateOnFGSwitch, /* needs activate event following
/* major switch */
doesActivateOnFGSwitch; /* activates own windows in
/* response to OS events */
boolean backgroundAndForeground, /* app has a user interface */
onlyBackground; /* app has no user interface */
boolean dontGetFrontClicks, /* don't return mouse events */
/* in front window on resume */
getFrontClicks; /* do return mouse events
/* in front window on resume */
boolean ignoreAppDiedEvents, /* applications use this */
acceptAppDiedEvents; /* app launchers use this */
boolean not32BitCompatible, /* works with 24-bit addr */
is32BitCompatible; /* works with 24- or 32-bit addr */
boolean notHighLevelEventAware, /* can't use high-level events */
isHighLevelEventAware; /* can use high-level events */
boolean onlyLocalHLEvents, /* only local high-level events */
localAndRemoteHLEvents; /* also remote high-level events */
boolean notStationeryAware, /* can't use stationery documents */
isStationeryAware; /* can use stationery documents */
boolean dontUseTextEditServices, /* can't use inline services */
useTextEditServices; /* can use inline services */
boolean reserved; /* reserved */
boolean reserved; /* reserved */
boolean reserved; /* reserved */
/* memory sizes are in bytes */
unsigned longint; /* preferred memory size */
unsigned longint; /* minimum memory size */
};
The nonreserved bits in the flags field have the following meanings:
If you set the acceptSuspendResumeEvents flag, you should also set the doesActivateOnFGSwitch flag.
System 7-savvy applications should have the background processing bit set.
Some early versions of MultiFinder do not send application-died events, and your application should not depend on receiving them if it is running in System 6. These events are provided primarily for use by debuggers.
The numbers you specify as your application's preferred and minimum memory sizes depend on the particular memory requirements of your application. Your application's memory requirements depend on the size of your application's static heap, dynamic heap, A5 world, and stack. (See "Introduction to Memory Management" in Inside Macintosh: Memory for complete details about these areas of your application's partition.)
The static heap size includes objects that are always present during the execution of the application--for example, code segments, Toolbox data structures for window records, and so on.
Dynamic heap requirements depend on how many objects are created on a per- document basis (which may vary in size proportionally with the document itself) and the number of objects that are required for specific commands or functions.
The size of the A5 world depends on the amount of global data and the number of intersegment jumps the application contains.
Finally, the stack contains variables, return addresses, and temporary information. The application stack size varies among computers, so you should base your values for the stack size according to the stack size required on a Macintosh Plus (8 KB). The Process Manager automatically adjusts your requested amount of memory to compensate for the different stack sizes on different machines. For example, if you request 512 KB, more stack space (approximately 16 KB) will be allocated on machines with larger default stack sizes.